package com.example.teesystem.entityDto;

import com.example.teesystem.common.utils.FileUtil;
import com.example.teesystem.entity.Issue;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author : NieYaShi
 * @version : v1.0
 * @createTime : 2022/4/15 16:19
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class IssueBriefMessage {
    private Integer id;

    private String question;

    private String selectionA;

    private String selectionB;

    private String selectionC;

    private String selectionD;

    private Integer type;

    private List<String> urlList = new ArrayList<>();

    public IssueBriefMessage(Issue issue){
        BeanUtils.copyProperties(issue, this);
        String url = issue.getUrl().trim();
        if (!url.equals("")){
            String[] urls = url.split("\\$");
            for (String fileUrl : urls){
                urlList.add(FileUtil.FILE_PREFIX + fileUrl);
            }
        }
    }
}
